1 /*
2  * Copyright (C) 2008 The Android Open Source Project
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *  * Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  *  * Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in
12  *    the documentation and/or other materials provided with the
13  *    distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  */
28 
29 module android.ndk.api.level;
30 
31 import arsd.jni;
32 import android.ndk;
33 
34 extern (C):
35 nothrow:
36 @nogc:
37 
38 /**
39  * @file android/api-level.h
40  * @brief Functions and constants for dealing with multiple API levels.
41  */
42 
43 /**
44  * Magic version number for an Android OS build which has
45  * not yet turned into an official release,
46  * for comparisons against __ANDROID_API__.
47  */
48 enum __ANDROID_API_FUTURE__ = 10000;
49 
50 /**
51  * `__ANDROID_API__` is the API level being targeted. For the OS,
52  * this is `__ANDROID_API_FUTURE__`. For the NDK, this is set by the
53  * compiler/build system based on the API level you claimed to target.
54  */
55 enum __ANDROID_API__ = __ANDROID_API_FUTURE__;
56 
57 /** Names the Gingerbread API level (9), for comparisons against __ANDROID_API__. */
58 enum __ANDROID_API_G__ = 9;
59 
60 /** Names the Ice-Cream Sandwich API level (14), for comparisons against __ANDROID_API__. */
61 enum __ANDROID_API_I__ = 14;
62 
63 /** Names the Jellybean API level (16), for comparisons against __ANDROID_API__. */
64 enum __ANDROID_API_J__ = 16;
65 
66 /** Names the Jellybean MR1 API level (17), for comparisons against __ANDROID_API__. */
67 enum __ANDROID_API_J_MR1__ = 17;
68 
69 /** Names the Jellybean MR2 API level (18), for comparisons against __ANDROID_API__. */
70 enum __ANDROID_API_J_MR2__ = 18;
71 
72 /** Names the KitKat API level (19), for comparisons against __ANDROID_API__. */
73 enum __ANDROID_API_K__ = 19;
74 
75 /** Names the Lollipop API level (21), for comparisons against __ANDROID_API__. */
76 enum __ANDROID_API_L__ = 21;
77 
78 /** Names the Lollipop MR1 API level (22), for comparisons against __ANDROID_API__. */
79 enum __ANDROID_API_L_MR1__ = 22;
80 
81 /** Names the Marshmallow API level (23), for comparisons against __ANDROID_API__. */
82 enum __ANDROID_API_M__ = 23;
83 
84 /** Names the Nougat API level (24), for comparisons against __ANDROID_API__. */
85 enum __ANDROID_API_N__ = 24;
86 
87 /** Names the Nougat MR1 API level (25), for comparisons against __ANDROID_API__. */
88 enum __ANDROID_API_N_MR1__ = 25;
89 
90 /** Names the Oreo API level (26), for comparisons against __ANDROID_API__. */
91 enum __ANDROID_API_O__ = 26;
92 
93 /** Names the Oreo MR1 API level (27), for comparisons against __ANDROID_API__. */
94 enum __ANDROID_API_O_MR1__ = 27;
95 
96 /** Names the Pie API level (28), for comparisons against __ANDROID_API__. */
97 enum __ANDROID_API_P__ = 28;
98 
99 /** Names the "Q" API level (29), for comparisons against __ANDROID_API__. */
100 enum __ANDROID_API_Q__ = 29;
101 
102 /**
103  * Returns the `targetSdkVersion` of the caller, or `__ANDROID_API_FUTURE__`
104  * if there is no known target SDK version (for code not running in the
105  * context of an app).
106  *
107  * The returned values correspond to the named constants in `<android/api-level.h>`,
108  * and is equivalent to the AndroidManifest.xml `targetSdkVersion`.
109  *
110  * See also android_get_device_api_level().
111  *
112  * Available since API level 24.
113  */
114 
115 int android_get_application_target_sdk_version ();
116 /* __ANDROID_API__ >= 24 */
117 
118 // android_get_device_api_level is a static inline before API level 29.
119 
120 /**
121  * Returns the API level of the device we're actually running on, or -1 on failure.
122  * The returned values correspond to the named constants in `<android/api-level.h>`,
123  * and is equivalent to the Java `Build.VERSION.SDK_INT` API.
124  *
125  * See also android_get_application_target_sdk_version().
126  */
127 int android_get_device_api_level ();
128